package scala.Functional

object MainOB {
   def main(args: Array[String]): Unit = {
      val factor = 3
      val aMap = (i:Int) => i + factor
      
      var list = List(1,2,3,4,5)
      val list1 = list map aMap
      list1.foreach(print)
      
      println("\n\n======\n\n")
      
      val  list3 : List[_] = List(1,List(List(1,2,Nil),3,4),Nil,"hung","khung",7,8,List("func","foo",Nil))
      val resultList = foo(list3)
      println(resultList)
      
      println("\n\n======\n\n")
      
      val s = "demo string"
      val p = new Persion("Hung")
      exec(foo, s, p)
   }
   
   def foo(l: List[_]):List[_] = 
      l flatMap {
         case head::tail => head::foo(tail)
         case Nil => Nil
         case x => List(x)
      }
   
   def hello = (n:String) => {println("hello "+n)}
   def sayHello(calBack:() => Unit){
      calBack()
   }
   
   def exec(calBack:(String,Persion) => String, s:String, p:Persion){
      val rs = calBack(s,p)
      println(rs)
   }
   
   def foo = (s:String, p:Persion) => {
       val hu = ";"
       s + hu+ "  " + p.toString();
   }
}

case class Persion(name:String)





